import { Block } from '@app/models/block'

const Blocks = new class {
    async first() {
        let record = await Block.findOne()
        if (record) {
            return record
        }
        
        record = new Block()
        record.number = 0
        return await record.save()
    }

    async update(number: number) {
        return await Block.getRepository().update({}, {number})
    }
}()

export { Blocks }
